package com.gc.business.service.impl;

import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gc.common.utils.StringUtils;
import org.springframework.stereotype.Service;
import com.gc.business.mapper.UpkeepRecordMapper;
import com.gc.business.domain.UpkeepRecord;
import com.gc.business.service.IUpkeepRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;

/**
 * 电梯保养记录 服务层实现
 * 
 * @author hruiyan
 * @date 2020-11-18
 */
@Slf4j
@Service
public class UpkeepRecordServiceImpl extends ServiceImpl<UpkeepRecordMapper, UpkeepRecord> implements IUpkeepRecordService {

    @Override
    public List<UpkeepRecord> list(UpkeepRecord upkeepRecord){
        LambdaQueryWrapper<UpkeepRecord> wrapper = new LambdaQueryWrapper<>();
        if(upkeepRecord != null){
            if(StringUtils.isNotEmpty(upkeepRecord.getRecordId())){
                wrapper.eq(UpkeepRecord::getRecordId, upkeepRecord.getRecordId());
            }
            if(StringUtils.isNotEmpty(upkeepRecord.getUpkeepId())){
                wrapper.eq(UpkeepRecord::getUpkeepId, upkeepRecord.getUpkeepId());
            }
            if(StringUtils.isNotEmpty(upkeepRecord.getReferUserId())){
                wrapper.eq(UpkeepRecord::getReferUserId, upkeepRecord.getReferUserId());
            }
            if(StringUtils.isNotEmpty(upkeepRecord.getAuditUserId())){
                wrapper.eq(UpkeepRecord::getAuditUserId, upkeepRecord.getAuditUserId());
            }
            if(StringUtils.isNotEmpty(upkeepRecord.getAuditStatus())){
                wrapper.eq(UpkeepRecord::getAuditStatus, upkeepRecord.getAuditStatus());
            }
            if(StringUtils.isNotEmpty(upkeepRecord.getScoreMark())){
                wrapper.eq(UpkeepRecord::getScoreMark, upkeepRecord.getScoreMark());
            }
            if(StringUtils.isNotEmpty(upkeepRecord.getAuditIdea())){
                wrapper.like(UpkeepRecord::getAuditIdea, upkeepRecord.getAuditIdea());
            }
            if(StringUtils.isNotEmpty(upkeepRecord.getCreateBy())){
                wrapper.eq(UpkeepRecord::getCreateBy, upkeepRecord.getCreateBy());
            }
            if(StringUtils.isNotEmpty(upkeepRecord.getCreateTime())){
                wrapper.eq(UpkeepRecord::getCreateTime, upkeepRecord.getCreateTime());
            }
            if(StringUtils.isNotEmpty(upkeepRecord.getUpdateBy())){
                wrapper.eq(UpkeepRecord::getUpdateBy, upkeepRecord.getUpdateBy());
            }
            if(StringUtils.isNotEmpty(upkeepRecord.getUpdateTime())){
                wrapper.eq(UpkeepRecord::getUpdateTime, upkeepRecord.getUpdateTime());
            }
            if(StringUtils.isNotEmpty(upkeepRecord.getRemark())){
                wrapper.eq(UpkeepRecord::getRemark, upkeepRecord.getRemark());
            }
        }
        return baseMapper.selectList(wrapper);
    }

    /**
     * 查询当前审核人记录
     * @param upkeepId
     * @param auditUserId
     * @return
     */
    @Override
    public UpkeepRecord selectAuditUserRecord(Long upkeepId,Long auditUserId){
        return baseMapper.selectAuditUserRecord(upkeepId,auditUserId);
    }
}
